package com.sky.demo.repository.impl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.RowBounds;
import org.realogic.cfm.persistence.mybatis.MyBatisDao;
import org.realogic.cfm.persistence.query.QueryCondition;
import org.springframework.stereotype.Repository;

import com.github.pagehelper.PageInfo;
import com.sky.demo.entity.EntityBill;
import com.sky.demo.repository.EntityBillDao;

/**
 * 业务单据-DAO对象
 * 
 * @see EntityBillDao
 */
@Repository("entityBillDao")
public class EntityBillDaoImpl extends MyBatisDao<EntityBill> implements EntityBillDao {

	public EntityBillDaoImpl() {
		super();
	}

	public int create(EntityBill aModel) {
		return insert(sqlID("create"), aModel);
	}

	public int update(EntityBill aModel) {
		return update(sqlID("update"), aModel);
	}

	public int remove(Long aKey) {
		return delete(sqlID("remove"), aKey);
	}

	public EntityBill read(Long aKey) {
		return selectOne(sqlID("read"), aKey);
	}

	public List<EntityBill> query(QueryCondition aCondition) {
		return this.selectList(sqlID("query"), aCondition);
	}

	public PageInfo<EntityBill> query(Map<String, Object> aCondition, int aPageNo, int aPageSize) {
		List<EntityBill> list = selectList(sqlID("query"), aCondition, new RowBounds(aPageNo, aPageSize));
		PageInfo<EntityBill> pageinfo = new PageInfo<EntityBill>(list);
		return pageinfo;
	}

	private final String mapperClassNamePrex = EntityBillDao.class.getName().concat(".");

	private String sqlID(String statement) {
		return mapperClassNamePrex.concat(statement);
	}

}